Jak modifikovat Open/Save Dialog
Otázka od: Ing. Petr Sikola
11. 10. 2004 15:39
Zdravim, ve sve aplikaci pouzivam JvOpenDialog2000 a JvSaveDialog2000.
Potreboval bych na tento dialog "pridat" jeden label a jeden combobox s
vlastnima items a jeho stav nastavit pred otevrenim a opet precist po
uzavreni dialogu (po execute). Udalost pri zmene itemindex pri
zobrazenem dialogu nepotrebuji.
Potreboval bych to nejjsednoduseji.
Dekuji na nakopnuti spravnym smerem.
S pozdravem
Ing. Petr Sikola
EFG CZ spol. s r.o.
tel.: 481 319 324
sikola@efg.cz
www.efg.cz
www.aktion.cz
Odpovedá: Pavel Lang
11. 10. 2004 16:48
Zdravim, radeji bych vytvoril ten dialog novy nez rozsirovat stavajici...
Nenapada me nic jineho nez tam dat hook - viz struktura.
Problem je, ze o tento dialog se stara samotny pan Windows funkce
GetOpenFileNameA z comdlg32.dll, takze neco jako modifikovat resource asi
nema moc smysl (kuriozity v anglickych Win)
Jestli nekdo napise takovy kod, budu sam taky rad, takove patlani se v API
je na me moc
Ale pozor! Na starsich verzich Windows se ukazuje puvodni stary dialog!!!
Ten 2000 style se nijak nekompiluje.
Resource lze z comdlg32.dll dostat napriklad Resource Hackerem (staci do
googlu reshack) nebo i tooly v Delphi (ResourceExplorer)
Unit JvWinDialogs;
...
type
TOpenFileNameEx = packed record
lStructSize: DWORD; // Size of the structure in bytes.
hWndOwner: HWND; // Handle that is the parent of the
dialog.
hInstance: HINST; // Application instance handle.
lpstrFilter: PAnsiChar; // String containing filter information.
lpstrCustomFilter: PAnsiChar; // Will hold the filter chosen by the
user.
nMaxCustFilter: DWORD; // Size of lpstrCustomFilter, in bytes.
nFilterIndex: DWORD; // Index of the filter to be shown.
lpstrFile: PAnsiChar; // File name to start with (and
retrieve).
nMaxFile: DWORD; // Size of lpstrFile, in bytes.
lpstrFileTitle: PAnsiChar; // File name without path will be
returned.
nMaxFileTitle: DWORD; // Size of lpstrFileTitle, in bytes.
lpstrInitialDir: PAnsiChar; // Starting directory.
lpstrTitle: PAnsiChar; // Title of the open dialog.
Flags: DWORD; // Controls user selection Options.
nFileOffset: Word; // Offset of file name in
filepath=lpstrFile.
nFileExtension: Word; // Offset of extension in
filepath=lpstrFile.
lpstrDefExt: PAnsiChar; // Default extension if no extension
typed.
{---->}
lCustData: LPARAM; // Custom data to be passed to hook.
lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM;
lParam: LPARAM): UINT stdcall; // Hook.
{<----}
lpTemplateName: PAnsiChar; // Template dialog, if applicable.
// Extended structure starts here.
pvReserved: Pointer; // Reserved, use nil.
dwReserved: DWORD; // Reserved, use 0.
FlagsEx: DWORD; // Extended Flags.
end;
----- Original Message -----
From: "Ing. Petr Sikola" <developer@efg.cz>
To: <delphi-l@clexpert.cz>
Sent: Monday, October 11, 2004 4:36 PM
Subject: Jak modifikovat Open/Save Dialog
> Zdravim, ve sve aplikaci pouzivam JvOpenDialog2000 a JvSaveDialog2000.
> Potreboval bych na tento dialog "pridat" jeden label a jeden combobox s
> vlastnima items a jeho stav nastavit pred otevrenim a opet precist po
> uzavreni dialogu (po execute). Udalost pri zmene itemindex pri
> zobrazenem dialogu nepotrebuji.
>
> Potreboval bych to nejjsednoduseji.
> Dekuji na nakopnuti spravnym smerem.
>
> S pozdravem
>
> Ing. Petr Sikola
> EFG CZ spol. s r.o.
> tel.: 481 319 324
> sikola@efg.cz
> www.efg.cz
> www.aktion.cz
>
>
>
>
>
Odpovedá: L?ikola Petr
11. 10. 2004 18:30
no ja jsem myslel, kdyby to slo i nejak jinak, melo by to ve vysledku vypadat
nejak jako opendialog v notepadu v W2000 nebo ve WXP, akorat s jinyma polozkama
v tom druhem combu.
Jeste dodam ze je to v D5.
Petr Sikola
> Zdravim, radeji bych vytvoril ten dialog novy nez rozsirovat stavajici....
> Nenapada me nic jineho nez tam dat hook - viz struktura.
> {---->}
> lCustData: LPARAM; // Custom data to be passed to hook.
> lpfnHook: function(Wnd: HWND; Msg: UINT; wParam: WPARAM;
> lParam: LPARAM): UINT stdcall; // Hook.
> {<----}
Odpovedá: Ludek ZITA
11. 10. 2004 18:43
On Behalf Of L?ikola Petr
> no ja jsem myslel, kdyby to slo i nejak jinak, melo by to ve
> vysledku vypadat nejak jako opendialog v notepadu v W2000
> nebo ve WXP, akorat s jinyma polozkama v tom druhem combu.
> Jeste dodam ze je to v D5.
Ahoj.
Ja to delal v OnShow :
procedure TForm1.OpenDialog1Show(Sender: TObject);
var
Wnd: HWND;
Pozice: TRect;
begin
Wnd := GetWindowLong((Sender as TCommonDialog).Handle,
GWL_HWNDPARENT);
GetWindowRect(Wnd, Pozice);
SetWindowPos(Wnd, 0, 0, 0, Pozice.Right - Pozice.Left, Pozice.Bottom -
Pozice.Top + 30, SWP_NOZORDER or SWP_NOMOVE);
if FPanel = nil then
FPanel := TPanel.Create((Sender as TCommonDialog));
with FPanel do
begin
Name := 'DialogPanel';
Caption := '';
SetBounds(8, Pozice.Bottom - Pozice.Top - 26, Pozice.Right -
Pozice.Left -
24, 30);
BevelOuter := bvLowered;
//Color := 200;
ParentWindow := Wnd;
end;
if FLabel1 = nil then
FLabel1 := TLabel.Create(OpenDialog1);
with FLabel1 do
begin
Parent := FPanel;
Left := (FPanel.Width - 385) div 2;
Top := 8;
Caption := 'Kod:';
end;
if FLanguage = nil then
FLanguage := TComboBox.Create(OpenDialog1);
with FLanguage do
begin
Name := 'Language';
Parent := FPanel;
Width := 135;
Left := FLabel1.Left + FLabel1.Width + 2;
Top := 4;
Style := csDropDownList;
OnChange := BoxChange;
Items.Add('bez konverze (Off)');
Items.Add('Windows CP1250 (Win)');
Items.Add('Latin 2 CP 852 (Lat)');
Items.Add('Kamenicky CP867 (Kam)');
Items.Add('ISO 8859-2 (ISO)');
if (DialogMode = 2) then
Items.Add('ASCII (Asc)')
else
Items.Add('----------------------------');
if (DialogMode = 1) then
Items.Add('Automaticky');
ItemIndex := TMPLang;
end;
if FLabel2 = nil then
FLabel2 := TLabel.Create(OpenDialog1);
with FLabel2 do
begin
Parent := FPanel;
Left := FLanguage.Left + FLanguage.Width + 6;
Top := 8;
Caption := 'CR/LF:';
end;
if FCRLF = nil then
FCRLF := TComboBox.Create(OpenDialog1);
with FCRLF do
begin
Parent := FPanel;
Name := 'CRLF';
Width := 92;
Left := FLabel2.Left + FLabel2.Width + 2;
Top := 4;
OnChange := BoxChange;
Style := csDropDownList;
Items.Add('bez konverze (Off)');
Items.Add('CRLF (Dos)');
Items.Add('LF (Unix)');
if (DialogMode = 1) then
Items.Add('Automaticky');
ItemIndex := TMPCRLF;
if FOEMbox = nil then
FOEMbox := TCheckBox.Create(OpenDialog1);
with FOEMbox do
begin
Parent := FPanel;
Name := 'OEM';
Left := FCRLF.Left + FCRLF.Width + 6;
Top := 7;
Caption := 'Zobrazit OEM';
Checked := False;
Alignment := taLeftJustify;
Width := 85;
if (DialogMode = 2) then
Enabled := False
else
Enabled := True;
end;
end;
end;
Ludek
Odpovedá: L?ikola Petr
11. 10. 2004 21:09
Diky, to je presne ono!
Petr Sikola
>
> Ahoj.
> Ja to delal v OnShow :
>
> procedure TForm1.OpenDialog1Show(Sender: TObject);
> var
> Wnd: HWND;
> Pozice: TRect;
>
> Ludek